package com.handa.documentManager.controller;

import com.handa.common.entity.Response;
import com.handa.documentManager.entity.DTO.ServerConfig;
import com.handa.documentManager.service.impl.SftpService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/documentManager/sftp/server")
public class SFTPServerController {
    @Resource
    private SftpService sftpService;

    @PostMapping("/connect")
    public Response<?> connect(@RequestBody ServerConfig config) throws Exception {
        sftpService.connect(config);
        return Response.success("Connected successfully");
    }

    @PostMapping("/disconnect")
    public Response<?> disconnect() {
        sftpService.disconnect();
        return Response.success("Disconnected successfully");
    }
}